package com.nulldev.util.uri.iwebkit.legacy.elements.image;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import com.nulldev.util.uri.iwebkit.legacy.element.Element;
import com.nulldev.util.uri.iwebkit.legacy.element.ElementType;

public class StaticImageElement extends Element{

	private BufferedImage img;
	public StaticImageElement(String id, String classID, String html, String css, String data, final BufferedImage img) {
		super(id, classID, html, css, data, ElementType.IMAGE);
		this.img = img;
	}

	@Override
	public void onLoad() {
	}

	@Override
	public void onRender(Graphics2D g2d, int x, int y, int width) {
		g2d.drawImage(this.img, x, y, null);
		g2d.setColor(Color.RED);
		g2d.drawRect(x, y, this.img.getWidth(), this.img.getHeight());
		final Font prevFont = g2d.getFont();
		g2d.setFont(this.default_font);
		g2d.drawString("static.image.element", x + 2, y + 10);
		g2d.setFont(prevFont);
		g2d.setColor(Color.WHITE);
		updateHeight(this.img.getHeight() + 2);
	}

}
